﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows.Controls;

namespace Studio77.ForestSounds
{
    public class AudioPlayHelper
    {

        static Popup popUp2 = new Popup();
        private static MediaElement effectPlayer = new MediaElement();

        public static void PlayEffectSound(string fileName)
        {
            popUp2.Child = effectPlayer;
            popUp2.IsOpen = true;
            effectPlayer.Stop();
            effectPlayer.Source = null;
            try
            {
                effectPlayer.Source = new Uri("Sounds/" + fileName, UriKind.RelativeOrAbsolute);
                effectPlayer.Volume = 1.0;
                effectPlayer.Play();
            }
            catch (Exception)
            {
                effectPlayer.Source = null;
                effectPlayer = null;
            }
        }
    }
}
